using System;

namespace Woz
{
    /// <summary>
    /// adds a new screen thumbnail to the associated screen thumbnail slider
    /// </summary>
    internal class AddNewScreenThumbnailAction : Woz.Action
    {
        /// <summary>
        /// default constructor
        /// </summary>
        /// <param name="pSlider">parent slider to execute action on</param>
        public AddNewScreenThumbnailAction(Woz.ScreenThumbnailSlider pSlider)
        {
            // save the parameters to our members
            this.mSlider = pSlider;
        }

        /// <summary>
        /// gets the name of the tool this action belongs to none in this case
        /// </summary>
        public override string ToolName
        {
            get
            {
                return "";
            }
        }

        /// <summary>
        /// gets whether this action can be propagated or not
        /// </summary>
        public override bool Propagatable
        {
            get
            {
                return false;
            }
        }

        /// <summary>
        /// adds a new screen thumbnail to the slider
        /// </summary>
        /// <param name="pScreen">not used for non propagateable action</param>
        protected override void OnExecute(Woz.Screen pScreen)
        {
            // tell the screen thumbnail slider to create a new screen thumbnail and save it
            this.mNewScreenThumbnail = this.mSlider.AddScreenThumbnail(this.mNewScreenThumbnail);
        }

        /// <summary>
        /// removes this new screen thumbnail from the slider
        /// </summary>
        /// <param name="pScreen">not used for non propagateable action</param>
        protected override void OnUnExecute(Woz.Screen pScreen)
        {
            // tell the screen thumbnail to remove the newly added screen thumbnail
            this.mSlider.RemoveScreenThumbnail(this.mNewScreenThumbnail);
        }

        /// <summary>
        /// slider on which we will add screen thumbnails to
        /// </summary>
        private Woz.ScreenThumbnailSlider mSlider;

        /// <summary>
        /// newly created screen thumbnail
        /// </summary>
        Woz.ScreenThumbnail mNewScreenThumbnail;
    }
}
